import {
	resolve
} from 'path'
import fs from 'fs-extra'
import {
	defineConfig
} from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'
import autoprefixer from "autoprefixer"; 
export default defineConfig(() => {
	
	return {
		// define: {
		// 	"ENV_CONFIG":ENV_CONFIG,
		// 	"process.env.config": ENV_CONFIG, //配置一
		// 	'process.env': process.env, //配置二
		// },
	 
		resolve: {
			alias: {
				"@": resolve(__dirname, "/pages"),
				"~": resolve(__dirname, ""),
			},
		},
		plugins: [
			uni(),

			// 自动导入配置
			AutoImport({
				imports: [
					// 预设
					'vue',
					'uni-app',
					"pinia"
				]
			})
		],
		build: {
			minify: 'terser',
			// terserOptions: {
			// 	compress: {
			// 		drop_console: true,
			// 	},
			// },
		},
		server: {
		           
		            proxy: {
		                '/aliyun': {
		                    target: 'https://nls-gateway-cn-shanghai.aliyuncs.com/stream/v1/tts',
		                    changeOrigin: true,
		                    rewrite: (path) => path.replace(/^\/aliyun/, '')
		                },
						'/huoshan': {
						    target: 'https://openspeech.bytedance.com/api/v1/tts',
						    changeOrigin: true,
						    rewrite: (path) => path.replace(/^\/huoshan/, '')
						}
		              
		            }
		        },
		css: {
			postcss: {
				plugins: [
					autoprefixer({
						// 自动添加前缀
						overrideBrowserslist: [
							"Android 4.1",
							"iOS 7.1",
							"Chrome > 31",
							"ff > 31",
							"ie >= 8",
							//'last 2 versions', // 所有主流浏览器最近2个版本
						],
						grid: true,
					}),
				],
			},
		},
	}
})